/*
 * @Author: chen haoxuan
 * @Date: 2021-06-28 21:25:24
 * @LastEditTime: 2021-06-28 21:42:23
 */
#include<iostream>
using namespace std;
class B
{
  public:
    B(int xx):x(xx){++count;x+=10;}
    virtual void show() const
    {
      cout<<count<<"_"<<x<<endl;
    }
    virtual ~B()
    {
      cout<<--count<<"_"<<x<<endl;
    }
  private:
    int x;
  protected:
    static int count;
};
class D:public B
{
  public:
    D(int xx,int yy):B(xx),y(yy)
    {
      ++count;
      y+=100;
    }
    void show() const
    {
      cout<<count<<"_"<<y<<endl;
    }
    ~D()
    {
      cout<<--count<<"_"<<y<<endl;
    }
  private:
    int y;
};
int B::count=0;
int main()
{
  B *pstr = new D(10,20);   // x=10,y=20 count=2
  pstr->show();             // 基类指针 调用D里的函数
  delete pstr;
  return 0;
}
/*
    2_120
    1_120
    0_20
*/